﻿using System;

namespace diantou.dataModel
{
    /// <summary>
    /// 考试回答问题
    /// </summary>
    [fastCSharp.emit.dataSerialize(IsReferenceMember = false, IsMemberMap = false)]
    public class examAnswerBase
    {
        /// <summary>
        /// 考试用户标识
        /// </summary>
        [fastCSharp.emit.dataMember(PrimaryKeyIndex = 1)]
        public int UserId;
        /// <summary>
        /// 考试问题标识
        /// </summary>
        [fastCSharp.emit.dataMember(PrimaryKeyIndex = 2)]
        public int QuestionId;
        /// <summary>
        /// 考试类型
        /// </summary>
        [fastCSharp.emit.dataMember(PrimaryKeyIndex = 3)]
        public examQuestion.type Type;
        /// <summary>
        /// 选择题答案
        /// </summary>
        public int Answer;

        /// <summary>
        /// 内容型答案
        /// </summary>
        [fastCSharp.emit.dataMember(Group = 1, MaxStringLength = judgeState.MaxProgramContentLength)]
        public string Content = string.Empty;

        /// <summary>
        /// 答案内容格式化
        /// </summary>
        public void FormatContent()
        {
            switch (Type)
            {
                case dataModel.examQuestionBase.type.Radio:
                    Content = string.Empty;
                    break;
                case dataModel.examQuestionBase.type.MultipleChoice:
                    if (Content.Length > 256) Content = Content.Substring(0, 256);
                    break;
                case dataModel.examQuestionBase.type.Question:
                    if (Content.Length > (16 << 10)) Content = Content.Substring(0, (16 << 10));
                    break;
                case dataModel.examQuestionBase.type.Problem:
                    if (Content.Length > judgeState.MaxProgramContentLength) Content = Content.Substring(0, judgeState.MaxProgramContentLength);
                    break;
            }
        }
    }
    /// <summary>
    /// 考试回答问题
    /// </summary>
    [fastCSharp.emit.jsonSerialize(IsAllMember = true)]
    [fastCSharp.emit.jsonParse(IsAllMember = true)]
    [fastCSharp.emit.dataSerialize(IsReferenceMember = false, IsMemberMap = false)]
    //[fastCSharp.code.cSharp.webView.clientType(Name = "diantou.examAnswer")]
    [fastCSharp.code.cSharp.sqlModel]
    public partial class examAnswer : examAnswerBase
    {
        /// <summary>
        /// 评分
        /// </summary>
        public int Point;
        /// <summary>
        /// 测试得分
        /// </summary>
        public int JudgePoint;
    }
}
